﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RemoteData.model.wave
{
    public class WaveLenDisplaySettingViewModel : ViewModelBase
    {
        private int m_nMaxGratting;
        public int nMaxGratting//最大光栅数量
        {
            get { return m_nMaxGratting; }
            set
            {
                if (value != this.m_nMaxGratting)
                {
                    this.m_nMaxGratting = value;
                    NotifyPropertyChanged();
                }
            }
        }
        private int m_nGratting;
        public int nGratting //光栅数量
        {
            get { return m_nGratting; }
            set
            {
                if (value != this.m_nGratting)
                {
                    this.m_nGratting = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private int m_nMaxChannel;
        public int nMaxChannel//最大通道数
        {
            get { return m_nMaxChannel; }
            set
            {
                if (value != this.m_nMaxChannel)
                {
                    this.m_nMaxChannel = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private int m_nChannel;
        public int nChannel //通道数量（暂时未用到）
        {
            get { return m_nChannel; }
            set
            {
                if (value != this.m_nChannel)
                {
                    this.m_nChannel = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private int m_maxTblFrequency;
        public int maxTblFrequency//表格最大刷新频率
        {
            get { return m_maxTblFrequency; }
            set
            {
                if (value != this.m_maxTblFrequency)
                {
                    this.m_maxTblFrequency = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private int m_tblFrequency;
        public int tblFrequency//波长显示table的刷新频率
        {
            get { return m_tblFrequency; }
            set
            {
                if (value != this.m_tblFrequency)
                {
                    this.m_tblFrequency = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private int m_maxChartFrequency;
        public int maxChartFrequency//图像最大刷新频率
        {
            get { return m_maxChartFrequency; }
            set
            {
                if (value != this.m_maxChartFrequency)
                {
                    this.m_maxChartFrequency = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private int m_chartFrequency;
        public int chartFrequency//图像的刷新频率
        {
            get { return m_chartFrequency; }
            set
            {
                if (value != this.m_chartFrequency)
                {
                    this.m_chartFrequency = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private int m_minDataCounts;
        public int minDataCounts//最小点数
        {
            get { return m_minDataCounts; }
            set
            {
                if (value != this.m_minDataCounts)
                {
                    this.m_minDataCounts = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private int m_maxDataCounts;
        public int maxDataCounts//最大点数
        {
            get { return m_maxDataCounts; }
            set
            {
                if (value != this.m_maxDataCounts)
                {
                    this.m_maxDataCounts = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private int m_dataCounts;
        public int dataCounts//点数
        {
            get { return m_dataCounts; }
            set
            {
                if (value != this.m_dataCounts)
                {
                    this.m_dataCounts = value;
                    NotifyPropertyChanged();
                }
            }
        }

        private ObservableCollection<double> m_referenceLines;
        public ObservableCollection<double> referenceLines//参考线
        {
            get { return m_referenceLines; }
            set
            {
                this.m_referenceLines = value;
                NotifyPropertyChanged();
            }
        }

        //波长的波动上限阙值
        private double m_upWaveLenThreshold;
        public double upWaveLenThreshold
        {
            get { return m_upWaveLenThreshold; }
            set
            {
                if (value != this.m_upWaveLenThreshold)
                {
                    this.m_upWaveLenThreshold = value;
                    NotifyPropertyChanged();
                }
            }
        }

        //波长的波动下限阙值
        private double m_lowWaveLenThreshold;
        public double lowWaveLenThreshold
        {
            get { return m_lowWaveLenThreshold; }
            set
            {
                if (value != this.m_lowWaveLenThreshold)
                {
                    this.m_lowWaveLenThreshold = value;
                    NotifyPropertyChanged();
                }
            }
        }

        //背景颜色
        private string m_warnBackColor;
        public string warnBackColor
        {
            get { return m_warnBackColor; }
            set
            {
                if (value != this.m_warnBackColor)
                {
                    this.m_warnBackColor = value;
                    NotifyPropertyChanged();
                }
            }
        }

        //文字颜色
        private string m_warnTextColor;
        public string warnTextColor
        {
            get { return m_warnTextColor; }
            set
            {
                if (value != this.m_warnTextColor)
                {
                    this.m_warnTextColor = value;
                    NotifyPropertyChanged();
                }
            }
        }

        //X轴自动调整
        private bool m_autoFitX;
        public bool autoFitX
        {
            get { return m_autoFitX; }
            set
            {
                if (value != this.m_autoFitX)
                {
                    this.m_autoFitX = value;
                    NotifyPropertyChanged();
                }
            }
        }

        //X轴显示范围
        private ValueRangeViewModel m_valueRangeX;
        public ValueRangeViewModel valueRangeX
        {
            get { return m_valueRangeX; }
            set
            {
                this.m_valueRangeX = value;
                NotifyPropertyChanged();
            }
        }


        //Y轴自动调整
        private bool m_autoFitY;
        public bool autoFitY
        {
            get { return m_autoFitY; }
            set
            {
                if (value != this.m_autoFitY)
                {
                    this.m_autoFitY = value;
                    NotifyPropertyChanged();
                }
            }
        }

        //Y轴显示范围
        private ValueRangeViewModel m_valueRangeY;
        public ValueRangeViewModel valueRangeY
        {
            get { return m_valueRangeY; }
            set
            {
                this.m_valueRangeY = value;
                NotifyPropertyChanged();
            }
        }

        public WaveLenDisplaySettingViewModel()
        {

        }

        public void Copy(WaveLenDisplaySetting setting)
        {
            this.nGratting = setting.nGratting;
            this.nMaxGratting = setting.nMaxGratting;

            this.nChannel = setting.nChannel;
            this.nMaxChannel = setting.nMaxChannel;

            this.tblFrequency = setting.tblFrequency;
            this.maxTblFrequency = setting.maxTblFrequency;

            this.chartFrequency = setting.chartFrequency;
            this.maxChartFrequency = setting.maxChartFrequency;

            this.minDataCounts = setting.minDataCounts;
            this.maxDataCounts = setting.maxDataCounts;
            this.dataCounts = setting.dataCounts;

            ObservableCollection<double> refLines = new ObservableCollection<double>();
            foreach (var v in setting.referenceLines)
            {
                refLines.Add(v);
            }

            this.referenceLines = refLines;

            this.upWaveLenThreshold = setting.upWaveLenThreshold;
            this.lowWaveLenThreshold = setting.lowWaveLenThreshold;
            this.warnBackColor = setting.warnBackColor;
            this.warnTextColor = setting.warnTextColor;

            this.autoFitX = setting.autoFitX;
            this.autoFitY = setting.autoFitY;
            this.valueRangeX = new ValueRangeViewModel();
            this.valueRangeX.minValue = setting.valueRangeX.minValue;
            this.valueRangeX.maxValue = setting.valueRangeX.maxValue;
            this.valueRangeY = new ValueRangeViewModel();
            this.valueRangeY.minValue = setting.valueRangeY.minValue;
            this.valueRangeY.maxValue = setting.valueRangeY.maxValue;
        }
        public void Copy(WaveLenDisplaySettingViewModel setting)
        {
            this.nGratting = setting.nGratting;
            this.nMaxGratting = setting.nMaxGratting;

            this.nChannel = setting.nChannel;
            this.nMaxChannel = setting.nMaxChannel;

            this.tblFrequency = setting.tblFrequency;
            this.maxTblFrequency = setting.maxTblFrequency;

            this.chartFrequency = setting.chartFrequency;
            this.maxChartFrequency = setting.maxChartFrequency;

            this.minDataCounts = setting.minDataCounts;
            this.maxDataCounts = setting.maxDataCounts;
            this.dataCounts = setting.dataCounts;

            ObservableCollection<double> refLines = new ObservableCollection<double>();
            foreach (var v in setting.referenceLines)
            {
                refLines.Add(v);
            }

            this.referenceLines = refLines;

            this.upWaveLenThreshold = setting.upWaveLenThreshold;
            this.lowWaveLenThreshold = setting.lowWaveLenThreshold;
            this.warnBackColor = setting.warnBackColor;
            this.warnTextColor = setting.warnTextColor;

            this.autoFitX = setting.autoFitX;
            this.autoFitY = setting.autoFitY;
            this.valueRangeX = new ValueRangeViewModel();
            this.valueRangeX.minValue = setting.valueRangeX.minValue;
            this.valueRangeX.maxValue = setting.valueRangeX.maxValue;
            this.valueRangeY = new ValueRangeViewModel();
            this.valueRangeY.minValue = setting.valueRangeY.minValue;
            this.valueRangeY.maxValue = setting.valueRangeY.maxValue;
        }

        public WaveLenDisplaySettingViewModel(WaveLenDisplaySetting setting)
        {
            Copy(setting);
        }

        public WaveLenDisplaySettingViewModel(WaveLenDisplaySettingViewModel setting)
        {
            Copy(setting);
        }


        public WaveLenDisplaySettingViewModel Clone()
        {
            return new WaveLenDisplaySettingViewModel(this);
        }

    }
}
